
#import "PUDTHTSelCell.h"

@implementation PUDTHTSelCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self initViews];
    }
    
    return  self;
}
-(void)initViews{
    
    _bgView=[[UIView alloc]init];
    _bgView.frame=CGRectMake(0, 0, _window_width, _window_width*0.192);
//    _bgView.layer.borderColor = [UIColor grayColor].CGColor;
//    _bgView.layer.borderWidth = 0.5f;
//    _bgView.layer.cornerRadius  = 10;
//    _bgView.layer.masksToBounds = YES;
//    _bgView.backgroundColor=[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1];
    [self.contentView addSubview:_bgView];
    
    
//    _xian =[[UIView alloc]init];
//    _xian.backgroundColor=[UIColor colorWithHex:0xF3F3F3];
//    [_bgView addSubview:_xian];
    
    _touImage=[[UIImageView alloc]init];
    _touImage.frame=CGRectMake(_window_width*0.042, _window_width*0.026,  _window_width*0.138, _window_width*0.138);
    _touImage.layer.masksToBounds = YES;
    _touImage.image=[UIImage imageNamed:@"head"];
    _touImage.layer.cornerRadius  = 7;
    [_bgView addSubview:_touImage];
    
    _titleLab=[[UILabel alloc]initWithFrame:CGRectZero];
    _titleLab.font =[UIFont boldSystemFontOfSize:16];
    _titleLab.frame=CGRectMake(_window_width*0.202, _window_width*0.026, _window_width*0.746, _window_width*0.061);
    _titleLab.text=@"#心动搭讪";
    _titleLab.textAlignment=NSTextAlignmentLeft;
    _titleLab.textColor=[UIColor blackColor];
//    _titleLab.backgroundColor=[UIColor redColor];
    [_bgView addSubview:_titleLab];
    

    
    
    _neirongLab=[[UILabel alloc]initWithFrame:CGRectZero];
    _neirongLab.font =[UIFont systemFontOfSize:12];
    _neirongLab.frame=CGRectMake(_window_width*0.042, 10, 52, 52);
    _neirongLab.numberOfLines=0;
    _neirongLab.text=@"内心真的不强大，真的好累，很想努力前进，";
    _neirongLab.textColor=[UIColor colorWithHex:0x999999];
//    _neirongLab.backgroundColor=[UIColor orangeColor];
    _neirongLab.textAlignment=NSTextAlignmentLeft;
    [_bgView addSubview:_neirongLab];
    
    NSString *numStr=@"1";
    NSString *topStr=[NSString stringWithFormat:@"热门TOP%@",numStr];
    NSString *s=[NSString stringWithFormat:@"%@ 晒出让Ta看一眼就想搭讪的心动自拍吧",topStr];
    
    self.neirongLab.frame = CGRectMake(_window_width*0.202, _window_width*0.101, _window_width*0.78, _window_width*0.063);
    NSMutableAttributedString *hogan1 = [[NSMutableAttributedString alloc] initWithString:s];
    [hogan1 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-Bold" size:14.0] range:NSMakeRange(0, s.length)];
    [hogan1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0xFF2F2F] range:NSMakeRange(0, s.length)];
    [hogan1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12] range:NSMakeRange(topStr.length, s.length-topStr.length)];
    [hogan1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHex:0x999999] range:NSMakeRange(topStr.length, s.length-topStr.length)];
    self.neirongLab.attributedText = hogan1;
    
  
}

//指定宽度下，求lab的高度
- (CGSize)labHeight:(UILabel*)lab {
    CGSize size = [lab.text boundingRectWithSize:CGSizeMake(lab.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:lab.font} context:nil].size;
    return size;
}
@end
